#include "SampleClient.h"
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <unistd.h>

int main() 
{
    //
    // Read the username and password from the terminal.
    //
    std::string login ;
    std::string password ;
    //
    printf ("Please, enter your login: ");
    std::cin >> login ;
    //
    password = getpass( "Please enter your password: " ) ;
    //
    // Create an instance of our sample client and try to log in to
    // the server.
    //
    SampleClient client ;
    client.addHost( "feed1.opentick.com", 10010 ) ;
    client.addHost( "feed2.opentick.com", 10010 ) ;
    //
    std::cout << "Logging in to the otFeed servers..." 
              << std::endl ;
    //
    // :KLUDGE: OTClient::login() takes two 'char*' arguments in the
    // current version of OTFeed. However, it should really take
    // 'const char*' arguments. In order to use the current version of
    // OTClient::login() we have to use a const_cast<> below. Hope
    // that this will be fixed in future versions.
    //
    client.login( const_cast<char*>( login.c_str() ), 
                  const_cast<char*>( password.c_str() ) ) ;
    //
    // Wait for the user to enter 'q' to quit. The user must press
    // ENTER after pressing 'q'.
    //
    while( 'q' != getchar() )
    {
        /* empty loop */
    }
    return EXIT_SUCCESS ;
}
